package com.neuedu.ssm.controller;

import com.neuedu.ssm.po.UmsUser;
import com.neuedu.ssm.service.IUserService;
import com.neuedu.ssm.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 金山
 * 项目：springmvc-learn
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2025/3/1814:33
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;


    @GetMapping("/{id}")
    public UmsUser getByid(@PathVariable long id){

        return userService.getById(id);
    }

    @GetMapping("/list")
    public List<UmsUser> list(){

        return userService.list();
    }


    /**
     * 更新
     * @param umsUser
     * @return
     */
    @PostMapping()
    public boolean update(@RequestBody UmsUser umsUser    ){

        if(umsUser.getUserid() != null ){
            return userService.update(umsUser);
        }else{
            return userService.save(umsUser);
        }
    }

    @DeleteMapping("/{id}")
    public boolean delete(@PathVariable long id){

       return  userService.delete(id);
    }



}
